#-*- coding: utf-8 -*-
#-------------------------------------------------------------------------------
# Number：     015
# Name:        Python the function of lambda
# Author:      SUMMVING
# Email:       summving@gmail.com
# Created:     2013/08/17  21:05
# Copyright:   (c) SUMMVING 2013
# Licence:     GPLv3
#-------------------------------------------------------------------------------

def f(x,y):
    print x*y

f(8,9)

g = lambda x,y : x * y         #lambda函数的效果与定义的函数一样
                               # 冒号前是参数，可有多个，用逗号隔开；冒号后是返回值
print g(8,9)
print g                        #输出：<function <lambda> at 0x04103570>

"""reduce函数"""
l = range(1,6)
def f1(x,y):
    return x*y
print reduce(f1,l)             #用reduce函数计算递归，结果：120

f2 = lambda x,y : x*y
print reduce(f2,l)